#ifndef ANIMATEDSPRITE_H
#define ANIMATEDSPRITE_H

#include "NonCopyable.h"

#include <SFML/Graphics.hpp>

#include <vector>

namespace sf
{
class RenderWindow;
class Texture;
class Sprite;
}

// TODO: Copiar idea de ejemplo de AnimatedSprite, pero el vector de rects se genera aquí
class AnimatedSprite : public sf::Transformable, public NonCopyable<AnimatedSprite>
{
public:
    AnimatedSprite(sf::Texture* texture, sf::Int32 sourceX, sf::Int32 sourceY, sf::Int32 width, sf::Int32 height, sf::Int32 fps, sf::Int32 numFrames, bool looped);
    ~AnimatedSprite();

    void Draw(sf::RenderWindow& window) const;

    void Update(sf::Int32 elapsed_time_ms);

private:
    sf::Texture* m_texture;
    sf::Sprite* m_sprite;

    std::vector<sf::IntRect> m_sourceRect;

    const sf::Int32 m_sourceX, m_sourceY;
    const sf::Int32 m_width, m_height;

    const bool m_looped;
    const sf::Int32 m_frameTime;
    const sf::Int32 m_numFrames;
    sf::Int32 m_elapsedTime;
    sf::Int32 m_currentFrame;
};

#endif // ANIMATEDSPRITE_H
